<template>
    <div>
        <el-link type="primary" href="/mycenter/addMember">添加会员</el-link>
        <el-table :data="mem.list" style="width: 100%">
          <el-table-column label="序号" type="index" width="80"></el-table-column>
          <el-table-column prop="memid" label="ID" width="80" align="center"></el-table-column>
          <el-table-column prop="headImg" label="头像" width="120">
            <template slot-scope="scope">
              <el-avatar :src="scope.row.headImg"></el-avatar>
            </template>
          </el-table-column>
            <el-table-column prop="memName" label="姓名" width="100"></el-table-column>
            <el-table-column prop="sex" label="性别" width="80"></el-table-column>
          <el-table-column prop="phone" label="手机号" width="160"></el-table-column>
            <el-table-column  label="状态" width="80">
                <template slot-scope="scope">
                    <el-switch
                            v-model="scope.row.status==0?false:true"
                            active-color="#13ce66"
                            inactive-color="#ff4949"
                            @change="handleStatus(scope.row)"
                    >
                    </el-switch>
                </template>
            </el-table-column>
          <el-table-column prop="createDate" label="创建时间" width="150" align="center" :show-overflow-tooltip="true"></el-table-column>

          <el-table-column prop="company" label="单位" width="80"></el-table-column>
          <el-table-column prop="specialty" label="专长" align="center"></el-table-column>
          <el-table-column prop="numberCard" label="号码牌" width="80"></el-table-column>
            <el-table-column label="操作" width="150">
                <template slot-scope="scope">
<!--                    <el-link type="primary" href="/mycenter/CheckMember">查看</el-link>-->
                    <el-button type="text" size="small" @click="handleDelete(scope.row.memid)">删除</el-button>
                </template>
            </el-table-column>
        </el-table>
    </div>
</template>

<script>
    import Table from '@/apis';
    export default {
        name: 'member',
        data() {
            return {
                id:1,
                membersData: [],
                currentPage: 1,
                total: 0,
                limit: 20,
              pageIndex: 0,
              pageSize :12,
              input:'',
              mem : [],

            };
        },
        // created() {
        //     this.getMemberByPage();
        // },
      mounted:function(){
        this.query();//需要触发的函数
      },
        methods: {


            // async getMemberByPage() {
            //     return await Table.getMemberByPage(this.currentPage, this.limit).then(res => {
            //         this.membersData = res.data.data;
            //         console.log(this.membersData);
            //     });
            // },
            handleShow(id){

                this.$router.push({path:'/mycenter/CheckMember',query:{Id:id}});

            },
            handleEdit(id){
                this.$router.push({path:'/mycenter/editorMember',query:{Id:id}});

            },
          handleDelete(memid){
            this.$axios.post(
                'http://localhost:7070/api/Administration/DelectMember',
                // that.$qs.stringify(obj)
             this.$qs.stringify({memid:memid})).then(function (response) {
              console.log("------------1-------------------")
              console.log(response.data);
              if(response.data){
                alert("删除成功！");
                location.reload();
              }else alert("删除失败！");

            })
          },

            handleStatus(value) {
                console.log(value)
                // value.status=!value.status
                let sta=''
                if(value.status){
                    sta = '0';
                    value.status=false;
                }else {
                    sta = '1';
                    value.status=true;
                }

                let that=this
                this.$axios.post(

                    'http://localhost:7070/api/Administration/UpdateMemberForEditStatus',
                    // that.$qs.stringify(obj)
                    this.$qs.stringify({memid:value.memid,status:sta}),
                ).then(function (response) {
                    if(response.data){
                        that.$message({
                            type: 'success',
                            message: '重置成功!',
                        })
                    }
                    else
                    {
                        that.$message({
                            type: 'error',
                            message: '重置失败!',
                        })
                    }
                    // this.query()
                })
            },
          query(){
            let that=this
            this.$axios.post(
                'http://localhost:7070/api/Administration/pViewPageTMember',
                this.$qs.stringify({pageIndex:that.pageIndex,pageSize:that.pageSize,expertName:that.input}),
            ).then(function (response) {
              console.log("------------1-------------------")
              console.log(response.data);
              // console.log(response.data[1]);
              that.mem = response.data;
              console.log("------------2-------------------")
              console.log(that.mem);
            })
          },


        }
    };
</script>

<style></style>
